package com.codechuan.hallo_internal.utils;

import android.annotation.SuppressLint;

import com.codechuan.hallo_internal.common.Constant;
import com.codechuan.hallo_internal.entity.SuccessOrder;
import com.codechuan.hallo_internal.entity.SysUserAccountNz;
import com.codechuan.hallo_internal.entity.SysUserConfigNz;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;

public class JDBCUtil {
    private static final String CLS = "com.mysql.jdbc.Driver"; // 引用的jar包Driver类
    private static final String URL = "jdbc:mysql://115.231.220.227:3309/ry-vue?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    private static final String USER = "root";
    private static final String PASSWORD = "DMct36ewjEYCFe8t";

    public static Connection conn; //连接对象
    public static Statement stmt; //命令集
    public static PreparedStatement pStmt; //预编译命令集
    public static ResultSet rs; //结果集

    //取得连接的方法：
    public static void getConnection() {
        try {
            Class.forName(CLS); //CLS需为静态
            conn = DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // 关闭数据库操作对象：
    public static void closeAll() {
        try {
            if (conn != null) {
                conn.close();
                conn = null;
            }
            if (stmt != null) {
                stmt.close();
                stmt = null;
            }
            if (pStmt != null) {
                pStmt.close();
                pStmt = null;
            }
            if (rs != null) {
                rs.close();
                rs = null;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }




}
